package com.uy.system.mapper;

import com.uy.system.model.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.uy.system.model.vo.SysUserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户信息表 Mapper 接口
 * </p>
 *
 * @author ly
 * @since 2024-03-22
 */
public interface SysUserMapper extends BaseMapper<SysUser> {

    @Select("""
        SELECT user_id userId, dept_id deptId, user_name userName, nick_name nickName, user_type userType, email, phonenumber, sex, avatar, PASSWORD, STATUS, del_flag delFlag,
        login_ip loginIp, login_date loginDate, create_dept createDept, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime, remark
        FROM sys_user
    """)
    List<SysUserVo> getSysUserList();

    @Select("""
        SELECT su.user_id userId, su.dept_id deptId, su.user_name userName, su.nick_name nickName,
        su.email, su.phonenumber, su.sex, su.avatar, su.PASSWORD, su.STATUS, su.del_flag delFlag,sur.role_id roleId
        FROM sys_user su
        join sys_user_role sur on su.user_id = sur.user_id
        where su.del_flag = 0 and su.user_id = #{userId}
    """)
    SysUserVo getSysUserInfo(@Param("userId") Long userId);
}
